<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="https://api.icathia.cn/layui/css/layui.css" />
    <script src="https://api.icathia.cn/layui/layui.js" type="text/javascript"></script>
    <script src="https://api.icathia.cn/layer/layer.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript"></script>
</head>
<body>

<div class="container">

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>学生信息列表</small>
                </h1>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 column">
            <a 	class="layui-btn"id="addstudent" >新增</a>
            <a class="layui-btn  layui-btn-normal"  href="${pageContext.request.contextPath}/student/allStudent">显示信息</a>
        </div>
        <div class="col-md-4 column"></div>
        <div class="col-md-4 column">
<%--            查询数据--%>
           <span class="layui-input-inline" style="color: red;font-weight: bold">${error}</span>
            <form action="${pageContext.request.contextPath}/student/queryStudent" method="post" >

                <div class="layui-input-inline">
                <input type="text" name="queryStudentName" id="" class="layui-input" placeholder="请输入查询信息">
                </div>
                <input type="submit" value="查询" class="layui-btn">

            </form>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column" >
            <table class="layui-table" id="demo0">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>生日</th>
                    <th>班级</th>
                    <th>性别</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody >

                <c:forEach items="${list}" var="c">
                    <tr>
                        <td>${c.stuID}</td>
                        <td>${c.stuNo}</td>
                        <td>${c.name1}</td>
                        <td>${c.birthday}</td>
                        <td>${c.stuClass}</td>
                        <td>${c.gender}</td>
                        <td>
                            <a class="layui-btn layui-btn-sm layui-btn-normal"  href="${pageContext.request.contextPath}/student/toUpdate?id=${c.stuID}">更改</a>
                            <a class="layui-btn layui-btn-sm layui-btn-danger" href="${pageContext.request.contextPath}/student/deleteStudent/${c.stuID}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    //添加
    $('#addstudent').on('click', function(){
        layer.open({
            type: 2,
            title: '添加学生信息',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            anim:1, //0-6的动画形式，-1不开启
            content: '${pageContext.request.contextPath}/student/toAddStudent'
        });
    });

//分页
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'demo0' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: ${list} //数据总数，从服务端得到
            ,limit:5
        });
    });

</script>

</body>
</html>